package com.ss.android.article.base.feature.detail2.config;

import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.view.View;
import android.widget.TextView;

import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.ss.android.article.base.app.AppData;

public class a {
    private static final String a;

    static {
        a = a.class.getSimpleName();
    }

    public a() {

    }

    public static void a(View view, int arg3) {
        if (view != null) {
            AppData.getInstance();
            String v0 = DetailStyleConfig.getDetailBackgroundColor(AppData.isNightMode());
            if (!android.support.design.a.isTextEmpty(v0)) {
                try {
                    b(view, Color.parseColor(v0));
                    return;
                } catch (Exception exception) {
                    Logger.d(a, exception.toString());
                }
            }
            b(view, arg3);
        }
    }

    public static void a(int arg3, TextView tv) {
        int v0 = 0;
        if (tv != null) {
            int v1 = AppData.getInstance().mFontSizePref;
            if (v1 < 0 || v1 > 3) {
                v1 = 0;
            }

            switch (arg3) {
                case 1: {
                    v0 = DetailStyleConfig.getNatantFontSize(v1);
                    break;
                }
                case 2: {
                    v0 = DetailStyleConfig.getVideoTitleFontSize();
                    break;
                }
                case 3: {
                    v0 = DetailStyleConfig.b();
                    break;
                }
                case 4: {
                    v0 = DetailStyleConfig.b(v1);
                    break;
                }
                case 5: {
                    v0 = DetailStyleConfig.c(v1);
                    break;
                }
            }

            if (v0 <= 0) {
                return;
            }
            tv.setTextSize(((float) v0));
        }
    }

    public static void a(int arg3, TextView arg4, int arg5) {
        int v0 = 0;
        if (arg4 != null) {
            int v1 = AppData.getInstance().mFontSizePref;
            if (v1 < 0 || v1 > 3) {
                v1 = 0;
            }

            switch (arg3) {
                case 1: {
                    v0 = DetailStyleConfig.getNatantFontSize(v1);
                    break;
                }
                case 2: {
                    v0 = DetailStyleConfig.getVideoTitleFontSize();
                    break;
                }
                case 3: {
                    v0 = DetailStyleConfig.b();
                    break;
                }
                case 4: {
                    v0 = DetailStyleConfig.b(v1);
                    break;
                }
                case 6:
                case 7:
                case 8: {
                    v0 = DetailStyleConfig.d(v1);
                    break;
                }
            }

            if (v0 > 0) {
                arg4.setTextSize(((float) v0));
                return;
            }

            if (arg5 <= 0) {
                return;
            }

            arg4.setTextSize(((float) arg5));
        }
    }

    public static void a(TextView arg1, ColorStateList arg2) {
        if (arg1 != null) {
            AppData.getInstance();
            ColorStateList v0 = DetailStyleConfig.g(AppData.isNightMode());
            if (v0 != null) {
                arg1.setTextColor(v0);
            } else {
                arg1.setTextColor(arg2);
            }
        }
    }

    public static void a(View arg1) {
        if (arg1 != null) {
            AppData.getInstance();
            StateListDrawable v0 = DetailStyleConfig.h(AppData.isNightMode());
            if (v0 != null) {
                UIUtils.setBackgroundDrawable(arg1, ((Drawable) v0));
            }
        }
    }

    public static void b(int arg3, TextView arg4) {
        if (arg4 != null) {
            AppData.getInstance();
            boolean v1 = AppData.isNightMode();
            String v0 = " ";
            switch (arg3) {
                case 2: {
                    v0 = DetailStyleConfig.b(v1);
                    break;
                }
                case 3: {
                    v0 = DetailStyleConfig.c(v1);
                    break;
                }
                case 4: {
                    v0 = DetailStyleConfig.d(v1);
                    break;
                }
                case 5: {
                    v0 = DetailStyleConfig.e(v1);
                    break;
                }
            }

            try {
                if (android.support.design.a.isTextEmpty(v0)) {
                    return;
                }

                arg4.setTextColor(Color.parseColor(v0));
            } catch (Exception v0_1) {
                Logger.d(a, v0_1.getMessage() + "Exception updateTextColor2 type = " + arg3);
            }
        }
    }

    public static void b(int arg3, TextView arg4, int arg5) {
        if (arg4 != null) {
            AppData.getInstance();
            boolean v1 = AppData.isNightMode();
            String v0 = " ";
            switch (arg3) {
                case 2: {
                    v0 = DetailStyleConfig.b(v1);
                    break;
                }
                case 3: {
                    v0 = DetailStyleConfig.c(v1);
                    break;
                }
                case 5: {
                    v0 = DetailStyleConfig.e(v1);
                    break;
                }
                case 6: {
                    v0 = DetailStyleConfig.f(v1);
                    break;
                }
            }

            try {
                if (android.support.design.a.isTextEmpty(v0)) {
                    arg4.setTextColor(arg5);
                } else {

                    arg4.setTextColor(Color.parseColor(v0));
                }
            } catch (Exception v0_1) {
                Logger.d(a, v0_1.getMessage() + "Exception updateTextColor3: type = " + arg3);
            }

        }
    }

    private static void b(View arg4, int arg5) {
        if (arg4 != null) {
            int v0 = arg4.getPaddingLeft();
            int v1 = arg4.getPaddingRight();
            int v2 = arg4.getPaddingTop();
            int v3 = arg4.getPaddingBottom();
            arg4.setBackgroundColor(arg5);
            arg4.setPadding(v0, v2, v1, v3);
        }
    }

    public static void b(View arg2) {
        if (arg2 != null) {
            AppData.getInstance();
            String v0 = DetailStyleConfig.getDetailBackgroundColor(AppData.isNightMode());
            try {
                if (android.support.design.a.isTextEmpty(v0)) {
                    return;
                }

                b(arg2, Color.parseColor(v0));
            } catch (Exception v0_1) {
                Logger.d(a, "Exception updateBackgroundColor2 : type = 1");
            }
        }
    }
}

